// CVisImage.h
// Developed by Yang Yu (yuy@janelia.hhmi.org), Sept 27, 2012
// 

#ifndef __CVISIMG_H__
#define __CVISIMG_H__

#include "CVisUtility.h"


//------------------------------------
/// nd image (XYZCT...) structure
//------------------------------------

// nD image class
template <class Tdata, class Tidx>
class Y_IMAGE
{
public:
    Y_IMAGE();
    ~Y_IMAGE();

public:
    void clean();
    void setImage(Tdata *p, Tidx *sz, Tidx imgdim);
    void initImage(Tidx *sz, Tidx imgdim); // init a zero image
    void initField(Tidx *sz, Tidx imgdim); // init a zero field
    void set4doffsets();
    void getMassCenter();
    void setRefChn(Tidx refcinput);
    void zeros();
    Tdata val4d(Tidx z, Tidx y, Tidx x, Tidx v);
    Tidx idx4d(Tidx z, Tidx y, Tidx x, Tidx v);

public:
    Tdata *pImg;
    Tidx *dims;

    DataKind dk; // image [c][z][y][x] field [z][y][x][v]
    DimType dimt; // 1D/2D/3D/4D
    DataType dt;

    Tidx refc; // reference color channel, 0 by default

    Tidx totalplxs;
    Tidx of3, of2, of1; // efficient index
    REAL *centroid; // mass center

    Tidx m; // number of feature points
};

//----------------------------
#include "CVisImage.hpp"
//----------------------------

#endif //__CVISIMG_H__
